package so.wy.servicecenter.businessbed.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import so.wy.servicecenter.base.exception.ServiceException;
import so.wy.servicecenter.base.exception.WebException;
import so.wy.servicecenter.base.frame.baseopt.BaseOptService;
import so.wy.servicecenter.base.frame.baseopt.BaseOptWeb;
import so.wy.servicecenter.base.frame.web.webhand.WebExceptionHandler;
import so.wy.servicecenter.businessbed.service.deposit.DepositDTO;
import so.wy.servicecenter.businessbed.service.deposit.DepositService;


@Service
@Scope("prototype")
public class DepositWeb extends BaseOptWeb<DepositDTO> {
    @Autowired
    private DepositService depositService;

    @Override
    protected BaseOptService getOptService() {
        return depositService;
    }

    @WebExceptionHandler
    public DepositDTO getOpenDeposit() throws WebException {
        try {
            return depositService.getOpenDeposit();
        } catch (ServiceException e) {
            throw exception(e);
        }
    }

    @WebExceptionHandler
    public void toggle(Long id){
        depositService.toggle(id);
    }
}
